import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/layout/index.vue'
//constantRoutes 静态路由 登陆，首页等。。。
export const constantRoutes = [
	{
		path: "/redirect", //解决刷新问题
		component: Layout,
		hidden: true,
		children: [
			{
				path: "/redirect/:path(.*)",
				component: () => import("@/views/redirect/index.vue"),
			},
		],
	},
	// {
	// 	path: "/",
	// 	name: "Dashboard",
	// 	redirect: "/dashboard",
	// 	meta: {
	// 		title: "首页",
	// 		icon: "House",
	// 	},
	// 	component: Layout,
	// 	children: [
	// 		{
	// 			path: "/dashboard",
	// 			component: () => import("@/views/dashboard/index.vue"),
	// 			name: "Dashboard",
	// 			meta: { title: "首页", icon: "dashboard", affix: true },
	// 		},
	// 	],
	// },
	{
		path: "/",
		name: "device",
		redirect: "/device",
		meta: {
			title: "连接",
			icon: "House",
		},
		component: Layout,
		children: [
			{
				path: "/device",
				component: () => import("@/views/device/index.vue"),
				name: "Device",
				meta: { title: "连接设备", icon: "dashboard", affix: true },
			},
		],
	},
	{
		path: "/console",
		name: "console",
		redirect: "/console-log",
		meta: {
			title: "控制台",
			icon: "House",
		},
		component: Layout,
		children: [
			{
				path: "/console-log",
				component: () => import("@/views/console/index.vue"),
				name: "Console",
				meta: { title: "控制台", icon: "dashboard", affix: true },
			},
		],
	},
	{
		path: "/usercenter",
		name: "usercenter",
		redirect: "/user-center",
		meta: {
			title: "个人中心",
			icon: "House",
		},
		component: Layout,
		children: [
			{
				path: "/user-center",
				component: () => import("@/views/user/center/index.vue"),
				name: "usercenter",
				meta: { title: "个人中心", icon: "dashboard", affix: true },
			},
		],
	},
	{
		path: "/login",
		name: "Login",
		meta: {
			title: "登录",
		},
		component: () => import("@/views/user/login/index.vue"),
		hidden: true,
	},
	// {
	// 	path: "/statistic",
	// 	name: "statistic",
	// 	redirect: "/statistic/inspect",
	// 	meta: {
	// 		title: "数据统计",
	// 		icon: "House",
	// 	},
	// 	component: Layout,
	// 	children: [
	// 		{
	// 			path: "/inspect",
	// 			component: () => import("@/views/statistic/inspect.vue"),
	// 			name: "inspect",
	// 			meta: { title: "检测记录", icon: "dashboard", affix: true },
	// 		},
	// 		{
	// 			path: "/inspect1",
	// 			component: () => import("@/views/statistic/inspect1.vue"),
	// 			name: "inspect1",
	// 			meta: { title: "班次统计", icon: "dashboard", affix: true },
	// 		},
	// 	],
	// },
	// {
	// 	path: "/statistic1",
	// 	name: "statistic1",
	// 	redirect: "/statistic1/inspect2",
	// 	meta: {
	// 		title: "标准模拟",
	// 		icon: "House",
	// 	},
	// 	component: Layout,
	// 	children: [
	// 		{
	// 			path: "/inspect2",
	// 			component: () => import("@/views/statistic/inspect2.vue"),
	// 			name: "inspect2",
	// 			meta: { title: "标准模拟", icon: "dashboard", affix: true },
	// 		},
	// 	],
	// },

	// {
	//     path: "/test",
	//     name: "Test",
	//     meta: {
	//         title: '测试'
	//     },
	//     component: () => import('@/views/test/test6.vue'),
	//     hidden: true
	// },
	{
		path: "/:pathMatch(.*)*", // 此写法解决动态路由页面刷新的 warning 警告
		component: () => import("@/views/user/error-page/404.vue"),
		hidden: true,
	},
];
//动态路由 asyncRoutes
export const asyncRoutes = [];
const router = createRouter({
	history: createWebHashHistory(),// hash模式,history是createWebHistory(地址栏不带#)，hash是createWebHashHistory（地址栏带#）
	routes: constantRoutes
})
export default router
// 1. 定义路由组件.
// 也可以从其他文件导入
// 2. 定义一些路由
// 每个路由都需要映射到一个组件。
// 我们后面再讨论嵌套路由。
